package com.fx.zmlzml.domain.dto;

import com.fx.zmlzml.entity.SysUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysUserDetailDTO implements UserDetails {

    private SysUser sysUser;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return List.of();
    }

    public Long getUserId() {
        return sysUser.getId();
    }

    @Override
    public String getPassword() {
        return sysUser.getPassword();
    }

    @Override
    public String getUsername() {
        return sysUser.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return sysUser.getAccountNonExpired();
    }

    @Override
    public boolean isAccountNonLocked() {
        return sysUser.getIsLocked();
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return sysUser.getCredentialsNonExpired();
    }

    @Override
    public boolean isEnabled() {
        return sysUser.getIsEnabled();
    }
}